/*
 * MIT License
 *
 * Copyright (c) 2020 wen.gu <454727014@qq.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/***************************************************************************
 * Name: kfa_types.h
 *
 * Purpose: base type define for kfa(key frame animation) mux/demux/encoder/decoder
 *
 * Developer:
 *   wen.gu , 2022-03-04
 *
 * TODO:
 *
 ***************************************************************************/

/******************************************************************************
 **    INCLUDES
 ******************************************************************************/
#ifndef __KFA_TYPES_H__
#define __KFA_TYPES_H__

#include <stdint.h>
#include <functional>

/******************************************************************************
 **    MACROS
 ******************************************************************************/
#define KFA_FCC(a, b, c, d)    (((uint32_t)a) | (((uint32_t)b) << 8) | (((uint32_t)c) << 16) | (((uint32_t)d) << 24))

/**skfa:  sequence key frame animation */
#define KFA_TYPE_FCC KFA_FCC('s', 'k', 'f', 'a')
/******************************************************************************
 **    TYPE DEFINITIONS
 ******************************************************************************/

enum class kfa_raw_type: uint8_t
{
    Unknown = 0,
    RGBA32,
    RGB24,
    YUV420,
    NV12
};

enum class kfa_codec_format: uint8_t
{
    Unknown = 0,
    LZ4     = 1,
    ZSTD    = 2,
    Tiny    = 3
};

struct kfa_header
{
    uint32_t fourcc = KFA_TYPE_FCC;
    uint16_t width = 0;
    uint16_t height = 0;
    kfa_raw_type raw_type = kfa_raw_type::Unknown;
    kfa_codec_format codec_format = kfa_codec_format::LZ4;
    uint8_t version = 1;    
    uint8_t reserved[20] = {0};
};

#if 0
struct kfa_packet
{
    //uint32_t raw_size; /** the size of 'data' after decode */
    uint32_t size;
    uint8_t* data;
};
#endif

struct KfaBuffer
{
    uint32_t size;
    uint8_t* buf;
    std::function<void(KfaBuffer&)> release;
};


/******************************************************************************
 **    CLASSES/FUNCTIONS DEFINITIONS
 ******************************************************************************/





#endif /** !__KFA_TYPES_H__ */

